package stream;

import pojo.UserInfo;

import java.util.ArrayList;

/**
 * 查询第一个元素
 */
public class FindFirst {
    public static void main(String[] args) {
        ArrayList<UserInfo> list = new ArrayList();
        list.add(new UserInfo(1, "张三", 1));
        list.add(new UserInfo(2, "李四", 2));
        list.add(new UserInfo(3, "王五", 3));
        list.add(new UserInfo(3, "赵六", 4));
        list.stream().findFirst().ifPresent(System.out::println);

        UserInfo userInfo = list.stream().findFirst().get();
        System.out.println(userInfo);
    }

}
